package com.softfuxi.tbs.app;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.softfuxi.tbs.app.feature.X5WebViewActivity;
import com.softfuxi.tbs.app.viewutils.FeatureManager;


public class AppMainActivity extends AppCompatActivity {

    private final String TAG = "NavigationActivity";

    private Button btn = null;
    private EditText ipadd = null;
    private EditText port = null;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.e("###", "click AppMainActivity");

        btn = findViewById(R.id.button);
        ipadd = findViewById(R.id.ipaddr);
        port = findViewById(R.id.port);
//        initNavList();
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("###", "click 888" + ipadd.getText());
                Log.e("###", "click 888" + port.getText());

                String url = "http://" + ipadd.getText() + ":" + port.getText();
//                Intent intent = new Intent();
//                intent.putExtra("url", url);
//                startActivity(intent);


                Intent intent = new Intent(getApplicationContext(), X5WebViewActivity.class);
                intent.putExtra("url", url);
                startActivity(intent);


//                Intent intent = new Intent(this, FeatureManager.getActivity(position));
//                intent.putExtra("url", FeatureManager.getUrl(position));
//                startActivity(intent);
            }
        });
    }

//    private void initNavList() {
//        ListView listView = (ListView) findViewById(R.id.list_base_func);
//        SectionListAdapter adapter = new SectionListAdapter(this);
//        listView.setAdapter(adapter);
//        listView.setOnItemClickListener(new OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
//                handleItem(position);
//            }
//        });
//        for (FeatureManager.FeatureItem item: FeatureManager.featureItems) {
//            if (item.type == FeatureManager.TYPE_SEPARATOR) {
//                adapter.addSectionHeaderItem(item.featureName);
//            } else {
//                adapter.addItem(item.featureName);
//            }
//        }
//    }
//
//    private void handleItem(int position) {
//        Intent intent = new Intent(this, FeatureManager.getActivity(position));
//        intent.putExtra("url", FeatureManager.getUrl(position));
//        startActivity(intent);
//    }

}
